package com.webssh.service.handler;

import java.io.IOException;

import org.springframework.web.socket.WebSocketSession;

import com.webssh.service.handler.process.SHProcessHandler;
import com.webssh.service.handler.terminal.TerminalHandler;

/**
 *  
 * @author zhanshuw
 *     	   2018年6月21日
 * 
 */
public class HandlerFactory {
	
	public static final String  HANDLERTYPE = "HandlerType";
	
	public static HandlerProcess getHandler(WebSocketSession ws) throws IOException{
		switch((HandlerType)ws.getAttributes().get(HANDLERTYPE)){
			case Process: {
				return new SHProcessHandler(ws);
			}
			case Terminal: {
				return new TerminalHandler(ws);
			}
		}
		return null;
	}
	
	public enum HandlerType{
		Terminal, Process;
	}

}
